<script setup lang="ts" name="HotZoneProperty">
import { usePropertyForm } from '@/components/Designer/utils/index'
import { HotZoneProperty } from './config'
import HotZoneEditDialog from './components/HotZoneEditDialog/index.vue'

/** 热区属性面板 */

const props = defineProps<{ modelValue: HotZoneProperty }>()
const emit = defineEmits(['update:modelValue'])
const { formData } = usePropertyForm(props.modelValue, emit)

// 热区编辑对话框
const editDialogRef = ref()
// 打开热区编辑对话框
const handleOpenEditDialog = () => {
  editDialogRef.value.open()
}
</script>

<template>
  <MallProperty v-model="formData.style">
    <!-- 表单 -->
    <ElForm label-width="80px" :model="formData" class="m-t-8px">
      <ElFormItem label="上传图片" prop="imgUrl">
        <UploadImage v-model="formData.imgUrl" height="50px" width="auto" class="min-w-80px">
          <template #tip>
            <ElText type="info" size="small"> 推荐宽度 750</ElText>
          </template>
        </UploadImage>
      </ElFormItem>
    </ElForm>

    <ElButton type="primary" plain class="w-full" @click="handleOpenEditDialog"> 设置热区 </ElButton>
  </MallProperty>
  <!-- 热区编辑对话框 -->
  <HotZoneEditDialog ref="editDialogRef" v-model="formData.list" :img-url="formData.imgUrl" />
</template>

<style scoped lang="scss">
.hot-zone {
  position: absolute;
  display: flex;
  font-size: 12px;
  color: #fff;
  cursor: move;
  background: #409effbf;
  border: 1px solid var(--el-color-primary);
  align-items: center;
  justify-content: center;

  /* 控制点 */
  .ctrl-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: #fff;
    border-radius: 50%;
  }
}
</style>
